<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vueJS/vue.js"></script>
</head>

<body>
    <div id="example">
        <p>
            Origin Message:{{message}}
        </p>
        <p>
            Computed reversedMessage: {{reversedMessage}}
        </p>
        <p>
            methods reversedMessage2:{{reversedMessage2()}}
        </p>
    </div>


    <div id="demo">
        {{ fullName }}
    </div>


</body>

</html>
<script type="text/javascript">

    var vmDemo = new VUe({
        el: '#demo',
        data: {
            firstName: 'Foo',
            lastName: 'Bar',
            fullName: 'Foo Bar'
        },
        watch: {
            firstName: function (val) {
                this.fullName = val + ' ' + this.lastName
            },
            lastName: function (val) {
                this.lastName = this.firstName + ' ' + val
            }
        }
    })

    var vmDemo2 = new Vue({
        el: 'demo',
        data: {
            firstName: 'Foo',
            lastName: 'Bar',
            fullName: 'Foo Bar'
        },
        cumputed: function () {
            return this.firstName + ' ' + this.lastName
        }
    })

    var vm = new Vue({
        el: '#example',
        data: {
            message: 'Hello'
        },
        computed: {
            reversedMessage: function () {
                return this.message.split('').reverse().join('') + Date.now()
            }
        },
        methods: {
            reversedMessage2: function () {
                return this.message.split('').reverse().join('') + Date.now()
            }
        }
    })
</script>